var cursos = {
		init:function(){		
			var curso = this;
			$('#cursos').jqGrid({
	           url:'cursos/index',
	           datatype:'json',
	           mtype:'POST',
	           colNames:['id','codigo','Descripcion','Area','Creado','Estado'],
	           colModel:[
	               {name:"data[Curso][id]",hidden:true},
	               {name:"data[Curso][codigo]",index:'Curso.codigo',width:30,align:'left',sortable:true,editoptions:{maxlength:100, size:30},editable:true,editrules:{required:true},searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
	               {name:"data[Curso][descripcion]",index:'Curso.descripcion',width:50,align:'left',sortable:true,editoptions:{maxlength:250, size:30},editable:true,editrules:{required:true},searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
	              {name:"data[Curso][tipocurso]",index:'Curso.tipocurso',width:50,align:'left',
	            	   sortable:true,editoptions:{maxlength:40, size:15},editable:true,edittype:"select",
	            	   editrules:{required:true},editoptions:{value:"IDIOMA:IDIOMA"},	 
	            	   searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}
	            	   },  
	               {name:"data[Curso][created]",index:'Curso.created',width:60,align:'left',sortable:true,editable:false,searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
	               {name:"data[Curso][estado_id]",
				   		index:'Estado.descripcion',
						width:60,
						align:'left',
						editable: true,
						edittype:"select",
						editrules:{required:true},
						editoptions:{
							value:"1:Activo;2:Desactivo"
						},
						searchoptions:{
							sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']
						}
					}               
	           ],
		
			   pager:$('#cursos-pager'),
	           rowNum:10,
	           rowList:[10,20,30],
	           mtype: "POST",
	           viewrecords:true,
	           caption:'Cursos',
	           height:'180',
	           rownumbers: true,
	           sortname: "Curso.descripcion",
	           editurl: 'cursos/index'
	          
	                
	       });
	       $('#cursos').navGrid("#cursos-pager",{edit:true,add:true,del:true},
		   	{clearAfterEdit:false,reloadAfterSubmit:true, closeOnEscape:true, afterSubmit:curso.afterSubmit},
			{clearAfterAdd:true,reloadAfterSubmit:true, closeOnEscape:true,afterSubmit:curso.afterSubmit},
			{width:270,reloadAfterSubmit:true, closeOnEscape:true},
			{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew'],multipleSearch:true, closeOnEscape:true});
	       
		   $("#cursos").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
	       jQuery("#cursos").jqGrid('setGridWidth',$('#RightPane').width()-50);
			
		},
		//afterSubmit: function(response){var respuesta = JSON.parse(response.responseText);return [respuesta.respuesta,respuesta.mensaje];}
};